package org.example.system.controller.question;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.common.core.controller.BaseController;
import org.example.common.core.model.Result;
import org.example.common.core.model.TableDataInfo;
import org.example.system.model.question.dto.QuestionAddDTO;
import org.example.system.model.question.dto.QuestionEditDTO;
import org.example.system.model.question.dto.QuestionQueryDTO;
import org.example.system.model.question.vo.QuestionDetailVO;
import org.example.system.service.question.IQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : [Pashm]
 * @version : [v1.0]
 */
@RestController
@RequestMapping("/question")
@Tag(name = "题目管理接口")
public class QuestionController extends BaseController {

    @Autowired
    private IQuestionService questionService;

    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){
       return getTableDataInfo(questionService.list(questionQueryDTO));
    }

    @PostMapping("/add")
    public Result<Void> add(@RequestBody QuestionAddDTO questionAddDTO){
        return toResult(questionService.add(questionAddDTO));
    }

    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId){
        return Result.ok(questionService.detail(questionId));
    }

    @PutMapping("/edit")
    public Result<Void> edit(@RequestBody QuestionEditDTO questionEditDTO){
        return toResult(questionService.edit(questionEditDTO));
    }

    @DeleteMapping("/delete")
    public Result<Void> delete(Long questionId){
        return toResult(questionService.delete(questionId));
    }


}
